package qianFeng.day1;

import java.util.Scanner;

public class demo07 {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        boolean zhu=false;
        String user="";
        String pwd="";
        boolean deng=false;
        while (true) {
            // 大富翁抽奖系统
            System.out.println("********大富翁抽奖系统********");
            System.out.println("\t1，注册。");
            System.out.println("\t2，登录。");
            System.out.println("\t3，抽奖。");
            System.out.print("请选择菜单:");
            int key =scanner.nextInt();
            switch (key) {
                case 1:
                    System.out.println("[>注册]");
                    System.out.println("填写个人信息");
                    System.out.print("请输入用户名:");
                    user=scanner.next();
                    System.out.print("请输入密码:");
                    pwd=scanner.next();
                    int card=(int)(Math.random()*8999+1000);
                    System.out.println("注册成功请记好你的会员卡号");
                    System.out.println("用户名\t密码\t会员卡号");
                    System.out.println(user+"\t"+pwd+"\t"+card);
                    zhu=true;
                    break;
                case 2:
                    System.out.println("[>登录]");
                    if (zhu) {
                        System.out.print("请输入登录账号:");
                        String u=scanner.next();
                        System.out.print("请输入登录密码:");
                        String p=scanner.next();
                        if (u.equals(user)&&p.equals(pwd)) {
                            System.out.println("登录成功");
                            deng=true;
                        }else {
                            System.out.println("登录失败");
                        }
                    }else {
                        System.out.println("请先去注册");
                    }
                    break;
                case 3:
                    System.out.println("[>抽奖]");
                    if (deng) {
                        //数组
                        int u[]=new int[5];
                        for (int i = 0; i < u.length; i++) {
                            u[i]=(int)(Math.random()*8999+1000);
                        }
                        System.out.print("请输入你的4位会员卡号:");
                        int c=scanner.nextInt();
                        boolean s=false;
                        System.out.println("本日幸运卡号:");
                        for (int i = 0; i < u.length; i++) {
                            System.out.print(u[i]+"  ");
                            if (u[i]==c) {
                                s=true;
                            }
                        }
                        if (s) {
                            System.out.println("中奖啦");
                        }else {
                            System.out.println("未中奖");
                        }
                    }else {
                        System.out.println("未登录，请先登录");
                    }
                    break;
                default:
                    break;
            }
            System.out.print("是否继续:y/n");
            String k=scanner.next();
            if (k.equals("n")) {
                System.out.println("程序结束");
                break;
            }
        }
    }
}
